package com.qfeng.edu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author zeng
 * @version 1.0
 * @notes -
 */
@Controller
@RequestMapping("user")
public class HelloController {

    @GetMapping("login")
    public String login(){
        System.out.println("login--------------------");
        return "index";
    }

    /**
     * forward:控制器请求路径 --转发控制器
     * redirect:控制器请求路径 --重定向控制器
     * @return
     */

    //请求地址同一个试图，可以设置多个请求路径
    @RequestMapping(value = {"index","lv2"},method = RequestMethod.POST)
    public String index1(){
        System.out.println("add-redirect---------");
        return "redirect:index";
    }

    @RequestMapping("addr")
    public String redirect_index(){
        System.out.println("add-redirect---------");
        return "redirect:index";
    }

    @RequestMapping("addf")
    public String forward_index(){
        System.out.println("add-forward--------");
        return "forward:index";
    }

    @RequestMapping("addf")
    public String index(){
        System.out.println("add-forward--------");
        return "redirect:/a.html"; //强制重定向到视图
    }
}
